/*
 * @Author: lyuan2018
 * @Date: 2020-03-18 10:38:52
 * @Last Modified by: lyuan2018
 * @Last Modified time: 2020-03-23 16:55:33
 */
import { observable, action } from 'mobx';
import { WeaTableNew } from 'comsMobx';
import * as Api from '../../apis/votingList';

const { TableStore } = WeaTableNew;
const defaultState = {
  loading: false,
  listParams: {},
  fileListMap: {},
};
export default class SuggestionStore {
  @observable suggestTabble = new TableStore();
  @observable loading = defaultState.loading;
  @observable listParams = defaultState.listParams;

  @action setStoreState = (params = {}) => {
    Object.keys(params).forEach((key) => {
      this[key] = params[key];
    });
    return this;
  }

  @action
  getTableList = (params, initPage = false) => {
    this.loading = true;
    Api.doPersonOfInput(params).then(action((res) => {
      initPage ? this.suggestTabble.getDatas(res.sessionkey, 1) : this.suggestTabble.getDatas(res.sessionkey);
      this.fileListMap = res.imagefile || {};
      this.loading = false;
    }));
  }
}
